package thread;

public class SyncDemo3 {
    public static void main(String[] args) {
        Boo b1 = new Boo();
        Boo b2 = new Boo();
        Thread t1 = new Thread(()->{
            b1.dosome();
        });
        Thread t2 = new Thread(()->{
            b2.dosome();
        });
        t1.start();
        t2.start();
    }
}
class Boo{
    //public synchronized static void dosome(){
    public static void dosome(){
        synchronized (Boo.class) {
            Thread t = Thread.currentThread();
            System.out.println(t + "正在执行dosome方法");
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
            }
            System.out.println(t + "执行dosome方法完毕");
        }
    }
}